package com.oa.controller;


import com.oa.pojo.Property;
import com.oa.pojo.Result;
import com.oa.service.PropertyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags= "Property接口" )
@RestController
@RequestMapping("/Property")
public class PropertyController {
    @Autowired
    private PropertyService propertyService;
    @ApiOperation(value="查询property")
    @CrossOrigin
    @GetMapping("/select")
    public Result select(Property property){
        List<Property> pplist=propertyService.select(property);
        return Result.success(pplist);
    }
    @ApiOperation(value="添加property")
    @CrossOrigin
    @PostMapping("/insert")
    public Result insert(@RequestBody Property property){
        System.out.println("进入添加property接口");
        if(propertyService.insert(property)==1){
            return Result.success();
        }else{
            return Result.error("该用户已存在");
        }
    }
    @ApiOperation(value = "更新property信息")
    @CrossOrigin
    @PostMapping("/update")
    public Result update(@RequestBody Property property){
        System.out.println("进入property更新接口");
        int flag= propertyService.update(property);
        if(flag==1){
            return Result.success();
        }else{
            return Result.error("该用户不存在");
        }
    }
    @ApiOperation(value = "property删除接口")
    @CrossOrigin
    @PostMapping("/delete")
    public Result delete(Property property){
        System.out.println("进入property删除接口");
        int flag=propertyService.delete(property);
        if(flag==1){
            return Result.success();
        }else{
            return Result.error("该用户不存在");
        }
    }
}
